package com.hujinwen.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
 * Created by joe on 2020/3/16
 * <p>
 * json工具，这里使用jackson
 */
public class JsonUtils {

    private static final ObjectMapper OM = new ObjectMapper();

    public static ObjectNode newObjectNode() {
        return OM.createObjectNode();
    }

    public static ArrayNode newArrayNode() {
        return OM.createArrayNode();
    }

    public static String toString(Object obj) throws JsonProcessingException {
        return OM.writeValueAsString(obj);
    }

}
